

//
//  WYCMeController.m
//  51还款
//
//  Created by 中企互联 on 2017/10/30.
//  Copyright © 2017年 中企互联. All rights reserved.
//

#import "WYCMeController.h"
#import "WYCRealnameController.h"
#import "WYCAboutMeController.h"
#import "WYCMeWalletController.h"
#import "WYCSetDissController.h"
#import "WYCMessegeController.h"
#import "WYCHelpController.h"
#import "WYCPersonalCenterController.h"
#import "WYCMeTamController.h"
#import "SetGestureLockViewController.h"

@interface WYCMeController ()<UITableViewDelegate,UITableViewDataSource>


@property(nonatomic,strong)UITableView * tableView;
@end

@implementation WYCMeController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    //头像View
    [self setupportrait];
}

#pragma make --------->>>头像View
- (void)setupportrait{
    
    //界面背景颜色
    self.view.backgroundColor = WYCGlobalBg;
    UIView * backView = [[UIView alloc] init];
    backView.backgroundColor = bigredColor;
    backView.frame = CGRectMake(0, 0, ScreenWidth, 600 * px);
    [self.view addSubview:backView];
    
    //Nav添加控件
    UIView *navView = [[UIView alloc] init];
    navView.frame = CGRectMake(0, 40 * px, ScreenWidth, 160 * px);
    navView.backgroundColor = trpColor;
    [backView addSubview:navView];
    
    UIButton * remindButton = [[UIButton alloc] init];
    remindButton.frame = CGRectMake(40 * px, 80 * px, 80 * px, 80 * px);
    [remindButton addTarget:self action:@selector(remindButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [remindButton setImage:[UIImage imageNamed:@"messege"] forState:UIControlStateNormal];
    [navView addSubview:remindButton];
    
    UIButton * setButton = [[UIButton alloc] init];
    setButton.frame = CGRectMake(ScreenWidth - 120 * px, 80 * px, 80 * px, 80 * px);
    [setButton addTarget:self action:@selector(setButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [setButton setImage:[UIImage imageNamed:@"messege"] forState:UIControlStateNormal];
    [navView addSubview:setButton];
    
    
    UIImageView * photoImageView = [[UIImageView alloc] init];
    photoImageView.frame = CGRectMake(ScreenWidth / 2 - 130 * px, CGRectGetMaxY(navView.frame), 260 * px, 260 * px);
    photoImageView.layer.cornerRadius = photoImageView.width / 2;
    photoImageView.layer.masksToBounds = YES;
    [photoImageView setUserInteractionEnabled:YES];
    [photoImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showPictureClick)]];
    photoImageView.backgroundColor = [UIColor whiteColor];
    [backView addSubview:photoImageView];
    
    UILabel * namelabel = [[UILabel alloc] init];
    namelabel.frame = CGRectMake(photoImageView.x, CGRectGetMaxY(photoImageView.frame) + 40 * px, photoImageView.width, 60 * px);
    namelabel.font = [UIFont systemFontOfSize:MiddleFont];
    namelabel.textAlignment = NSTextAlignmentCenter;
    namelabel.textColor = wycwhiteColor;
    namelabel.text = @"张小龙";
    [backView addSubview:namelabel];
    self.tableView.tableHeaderView = backView;
    
    
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(backView.frame), ScreenWidth, cellHeight * 7 + 30 * px) style:UITableViewStylePlain];
    //    self.tableView.backgroundColor = [UIColor redColor];
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    self.tableView.delegate = self;
    [self.view addSubview:self.tableView];
    
    
    UILabel * showlabel = [[UILabel alloc] init];
    showlabel.frame = CGRectMake(ScreenWidth / 2 - 260 * px, CGRectGetMaxY(self.tableView.frame) + 80 * px, 520 * px, 60 * px);
    showlabel.font = [UIFont systemFontOfSize:MiddleFont];
    showlabel.textAlignment = NSTextAlignmentCenter;
    showlabel.textColor = WYCRGBColor(168, 168, 168);
    showlabel.text = @"客服电话";
    [backView addSubview:showlabel];
    
    UILabel * iponelabel = [[UILabel alloc] init];
    iponelabel.frame = CGRectMake(ScreenWidth / 2 - 260 * px, CGRectGetMaxY(showlabel.frame) + 40 * px, 520 * px, 60 * px);
    iponelabel.font = [UIFont systemFontOfSize:MiddleFont];
    iponelabel.textAlignment = NSTextAlignmentCenter;
    iponelabel.textColor = bigredColor;
    iponelabel.text = @"4008-1212-3312";
    [backView addSubview:iponelabel];
    
    
    
    
    
   
    
}

#pragma make -------->>数据代理  数据源方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 8;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 5) {
        return 30 * px;
    }else{
    return cellHeight;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    tableView.tableFooterView = [[UIView alloc] init];
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"123"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"123"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row == 5) {
        
    }else{
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
    }
    CGFloat cellX = 40 * px;
    CGFloat cellY = 40 * px;
    CGFloat cellW = 240 * px;
    CGFloat imageW = 80 * px;
//    CGFloat imageH = 80 * px;
    
    if (indexPath.row == 0) {
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UIImageView * cellImage = [[UIImageView alloc] init];
        cellImage.image = [UIImage imageNamed:@"me_rate"];
        cellImage.frame = CGRectMake(cellX, cellY, imageW, imageW);
        [cellView addSubview:cellImage];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(CGRectGetMaxX(cellImage.frame) + cellX, cellImage.y, cellW, cellImage.height);
        pushtitle.text = @"实名认证";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
    }else if (indexPath.row == 1){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UIImageView * cellImage = [[UIImageView alloc] init];
        cellImage.image = [UIImage imageNamed:@"me_rate"];
        cellImage.frame = CGRectMake(cellX, cellY, imageW, imageW);
        [cellView addSubview:cellImage];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(CGRectGetMaxX(cellImage.frame) + cellX, cellImage.y, cellW, cellImage.height);
        pushtitle.text = @"我的钱包";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
    }else if (indexPath.row == 2){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UIImageView * cellImage = [[UIImageView alloc] init];
        cellImage.image = [UIImage imageNamed:@"me_rate"];
        cellImage.frame = CGRectMake(cellX, cellY, imageW, imageW);
        [cellView addSubview:cellImage];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(CGRectGetMaxX(cellImage.frame) + cellX, cellImage.y, cellW, cellImage.height);
        pushtitle.text = @"费率信息";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
    }else if (indexPath.row == 3){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UIImageView * cellImage = [[UIImageView alloc] init];
        cellImage.image = [UIImage imageNamed:@"me_rate"];
        cellImage.frame = CGRectMake(cellX, cellY, imageW, imageW);
        [cellView addSubview:cellImage];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(CGRectGetMaxX(cellImage.frame) + cellX, cellImage.y, cellW, cellImage.height);
        pushtitle.text = @"邀请好友";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
    }else if (indexPath.row == 4){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UIImageView * cellImage = [[UIImageView alloc] init];
        cellImage.image = [UIImage imageNamed:@"me_rate"];
        cellImage.frame = CGRectMake(cellX, cellY, imageW, imageW);
        [cellView addSubview:cellImage];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(CGRectGetMaxX(cellImage.frame) + cellX, cellImage.y, cellW, cellImage.height);
        pushtitle.text = @"我的团队";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
    }else if (indexPath.row == 5){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, 30 * px);
        cellView.backgroundColor = WYCGlobalBg;
        [cell addSubview:cellView];
        
        
    }else if (indexPath.row == 6){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UIImageView * cellImage = [[UIImageView alloc] init];
        cellImage.image = [UIImage imageNamed:@"me_rate"];
        cellImage.frame = CGRectMake(cellX, cellY, imageW, imageW);
        [cellView addSubview:cellImage];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(CGRectGetMaxX(cellImage.frame) + cellX, cellImage.y, cellW, cellImage.height);
        pushtitle.text = @"帮助中心";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
    }else {
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UIImageView * cellImage = [[UIImageView alloc] init];
        cellImage.image = [UIImage imageNamed:@"me_rate"];
        cellImage.frame = CGRectMake(cellX, cellY, imageW, imageW);
        [cellView addSubview:cellImage];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(CGRectGetMaxX(cellImage.frame) + cellX, cellImage.y, cellW, cellImage.height);
        pushtitle.text = @"关于我们";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        WYCRealnameController * realname = [[WYCRealnameController alloc] init];
        [self.navigationController pushViewController:realname animated:NO];
    }
    if (indexPath.row == 1) {
        WYCMeWalletController * mewallet = [[WYCMeWalletController alloc] init];
        [self.navigationController pushViewController:mewallet animated:NO];
    }
    
    
    if (indexPath.row == 4) {
        WYCMeTamController * meTam = [[WYCMeTamController alloc] init];
        [self.navigationController pushViewController:meTam animated:NO];
    }
    if (indexPath.row == 6) {
        WYCHelpController * help = [[WYCHelpController alloc] init];
        [self.navigationController pushViewController:help animated:NO];
    }
    if (indexPath.row == 7) {
        WYCAboutMeController * aboutMe = [[WYCAboutMeController alloc] init];
        [self.navigationController pushViewController:aboutMe animated:NO];
    }
    
}
#pragma make ------>>消息点击事件
- (void)remindButtonClick{
    WYCLogFunc;
    WYCMessegeController * messege = [[WYCMessegeController alloc] init];
    [self.navigationController pushViewController:messege animated:NO];
    
}

#pragma make ------>>设置点击事件
- (void)setButtonClick
{
    WYCLogFunc;
    WYCSetDissController * setdiss = [[WYCSetDissController alloc] init];
    [self.navigationController pushViewController:setdiss animated:NO];
}
#pragma make ------>>进入控制器隐藏
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}
#pragma make ------>>离开控制器显示
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

#pragma make ------->>点击头像跳转
- (void)showPictureClick{
    WYCPersonalCenterController * PersonalCenter = [[WYCPersonalCenterController alloc] init];
    [self.navigationController pushViewController:PersonalCenter animated:NO];
         
 }
@end
